package com.mmd.base.exception;

import com.mmd.core.enums.BaseEnum;
import com.mmd.core.enums.ResultEnum;
import lombok.Data;
import org.apache.dubbo.rpc.RpcException;

@Data
public class RpcRuntimeException extends RpcException {
    private static final long serialVersionUID = -159433994674523022L;
    private int code;
    private String message;

    public RpcRuntimeException() {
        this(ResultEnum.ERROR_NETWORK);
    }

    public RpcRuntimeException(BaseEnum baseEnum) {
        this(Integer.parseInt(baseEnum.getCode()),baseEnum.getMessage());
    }

    public RpcRuntimeException(String message) {
        this(Integer.parseInt(ResultEnum.ERROR.getCode()),message);
    }

    public RpcRuntimeException(int code, String message) {
        this.code = code;
        this.message = message;
    }
}
